home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / ENTRIES.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-22  |  1.2 KB  |  49 lines

  1. /*
  2.  * directory access --- The POSIX way
  3.  *
  4.  * W/ 1996 by Eero Tamminen, t150315@cc.tut.fi
  5.  * Extended by Craig
  6.  */
  7. /* directory name space allocator configuration defines */
  8. #ifndef POINTER_ALIGN
  9. #define POINTER_ALIGN    (sizeof(void*))
  10. #endif
  11. #define BLOCK_SIZE    128
  12.  
  13. /* entry in the read directory */
  14. typedef struct ENTRY
  15. {
  16.   struct ENTRY *next;
  17.   long flags;
  18.   long size;
  19. } Entry;
  20. /* followed with the name string */
  21.  
  22. /* sort entries returns two char*[] arrays, names of directories and
  23.  * files, from the given entry list for the fileselector listbox widgets.
  24.  */
  25. typedef struct
  26. {
  27.   char **dirs;
  28.   short num_dirs;
  29.   char **files;
  30.   short num_files;
  31. } Lists;
  32.  
  33. /* Memory handling / usage:
  34.  *
  35.  * pointer aligning is needed for the structures after strings in the
  36.  * blocks.  One block can contain at least (BLOCK_SIZE / (NAME_MAX +
  37.  * POINTER_ALIGN + sizeof(void*) * 3)) directory entries.  Using
  38.  * sort_entries() will take further sizeof(char*) / entry.
  39.  */
  40.  
  41. /* directory entry flags */
  42. #define FLAG_DIR    1
  43. #define FLAG_EXECUTABLE 2
  44. #define FLAG_LINK    4
  45.  
  46. Entry *read_entries(char *dir);
  47. Lists *sort_entries(char *mask);
  48. void free_entries(void);
  49.